/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

const randomValue = list => list[parseInt(Math.random() * list.length)];
const randomOrderDetail = () => {
  const state = ["已出库", "待出库"];
  const brands = [
    { brand: "sto", short_name: "申通" },
    { brand: "zt", short_name: "中通" },
    { brand: "yt", short_name: "圆通" },
    { brand: "yd", short_name: "韵达" },
  ];
  const status = randomValue(state);
  const { brand, short_name } = randomValue(brands);
  return {
    status_cn: status,
    brand,
    brand_cn: short_name,
  };
};

export default {
  "POST /Api/YZ/CourierStation/superSearch": (req, res) => {
    const list = [];
    Array.from({
      length: 10,
    }).map((item, index) => {
      list.push({
        id: `34488785${index}`,
        waybill_no: `464634553454${index}`,
        phone: "18311111111",
        pickup_code: "A01",
        cm_id: `cm_id_${index}`,
        ...randomOrderDetail(),
      });
    });
    res.send({
      msg: "暂无结果",
      code: req.body.keyword === "11111111" ? 1 : 0,
      data: list,
    });
  },
  "POST /Api/YZ/CourierStation/searchDetail": (req, res) => {
    res.send({
      msg: "暂无结果",
      code: req.body.keyword === "11111111" ? 1 : 0,
      data: {
        data: [
          {
            picture_invalid: 0,
            picture: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png",
            create_time: "2019-03-03 14:51:20",
            type: randomValue(["2", "3", "4", "5", "6"]),
            inn_name: "远大佳兆业",
            operator: "18111111111",
            desc: "描述",
          },
        ],
        gp_record_list: [
          {
            create_time: "2021-09-09 13:51:20",
            waybill_type_text: randomValue([
              "发件扫描",
              "到件扫描",
              "派件扫描",
              "签收扫描",
              "问题件扫描",
            ]),
            waybill_no: "123123123",
            waybill_type: randomValue(["2", "3", "4", "5", "6"]),
            next_station: "123",
            next_station_name: "下一站名称",
            operator_phone: "16677778888",
            sign_man: " 签收人",
            bad_waybill_type: "问题件大类",
            bad_waybill_desc: "问题件小类",
            bad_waybill_describe: "问题件描述",
            delivery_phone: "派件人手机号",
            delivery_name: "派件人姓名",
          },
        ],
      },
    });
  },
};
